<template>
  <div>
    <el-tabs v-model="activeKey" @tab-click="tabClick">
      <el-tab-pane label="应付账款明细" name="1"></el-tab-pane>
      <el-tab-pane
        v-if="
          getUserInfo().userType == 'main_user' ||
          getUserInfo().userType == 'main_admin'
        "
        label="结算批次管理"
        name="2"
      ></el-tab-pane>
    </el-tabs>

    <el-card style="min-width: 1200px">
      <div class="tableSelectWrap">
        <el-form
          ref="caseAccountDetailsForm"
          :model="commandForm"
          label-width="100px"
        >
          <el-row>
            <el-col :span="7">
              <el-form-item label="选择时间" prop="date">
                <el-date-picker
                  style="width: 100%"
                  v-model="commandForm.date"
                  :default-time="['00:00:00', '23:59:59']"
                  type="datetimerange"
                  start-placeholder="开始时间"
                  end-placeholder="结束时间"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  clearable
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col v-if="activeKey == '1'" :span="7" :offset="1">
              <el-form-item label="结算状态" prop="status">
                <el-select
                  v-model="commandForm.status"
                  style="width: 100%"
                  placeholder="请选择结算状态"
                  clearable
                >
                  <el-option label="所有" value=""></el-option>
                  <el-option label="未结算" value="created"></el-option>
                  <el-option label="待处理" value="waiting"></el-option>
                  <el-option label="处理中" value="pending"></el-option>
                  <el-option label="已结算" value="succeeded"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col v-if="activeKey=='1'" :span="7" :offset="1">
              <el-form-item label="结算方式" prop="type">
                <el-select
                  v-model="commandForm.royaltyWay"
                  style="width: 100%"
                  placeholder="请选择结算方式"
                  clearable
                >
                  <el-option label="所有" value=""></el-option>
                  <el-option label="余额" value="balance"></el-option>
                  <el-option label="支付宝" value="ali"></el-option>
                  <el-option
                    label="微信JSAPI/H5/native"
                    value="wx_js"
                  ></el-option>
                  <el-option label="微信小程序" value="wx_lite"></el-option>
                  <el-option label="微信APP" value="wx_app"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col v-if="activeKey=='2'" :span="7" :offset="1">
              <el-form-item label="结算方式" prop="type">
                <el-select
                  v-model="commandForm.settleChannel"
                  style="width: 100%"
                  placeholder="请选择结算方式"
                  clearable
                >
                  <el-option label="所有" value=""></el-option>
                  <el-option label="余额" value="balance"></el-option>
                  <el-option label="支付宝" value="ali"></el-option>
                  <el-option
                    label="微信JSAPI/H5/native"
                    value="wx_js"
                  ></el-option>
                  <el-option label="微信小程序" value="wx_lite"></el-option>
                  <el-option label="微信APP" value="wx_app"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col v-if="activeKey == '2'" :span="7" :offset="1">
              <el-form-item label="批次状态" prop="settleFinish">
                <el-select
                  v-model="commandForm.settleStatus"
                  style="width: 100%"
                  placeholder="请选择批次状态"
                  clearable
                >
                  <el-option label="所有" value=""></el-option>
                  <el-option label="已创建" value="created"></el-option>
                  <el-option label="处理中" value="pending"></el-option>
                  <el-option label="全部成功" value="succeeded"></el-option>
                  <el-option label="全部失败" value="failed"></el-option>
                  <el-option label="取消" value="canceled"></el-option>
                  <el-option
                    label="部分成功"
                    value="partially_succeeded"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col v-if="activeKey == '1'" :span="7">
              <el-form-item label="收款方" prop="merchantIds">
                <el-select
                  style="width: 100%"
                  v-model="commandForm.inUserId"
                  class="input_"
                  filterable
                  remote
                  clearable
                  placeholder="请输入用户名称或用户ID"
                  :remote-method="remoteMethod"
                  @change="setId($event)"
                  @focus="setId1()"
                >
                  <el-option
                    v-for="item of restaurants"
                    :key="item.id"
                    :label="item.userName"
                    :value="item.id"
                    class="height70"
                  >
                    <div
                      style="
                        color: #999999;
                        overflow: hidden;
                        white-space: nowrap;
                        text-overflow: ellipsis;
                        width: 350px;
                      "
                    >
                      {{ item.userName }} 用户ID :{{ item.userNo }}
                    </div>
                  </el-option>
                </el-select>
                <!-- <el-merchant-vue
                  v-model="commandForm.merchantId"
                  clearable
                ></el-merchant-vue> -->
              </el-form-item>
            </el-col>
            <el-col
              :span="7"
              :offset="activeKey == '1' ? '1' : '0'"
              style="min-width: 170px"
            >
              <el-button class="width120" @click="this.resetFields"
                >重置</el-button
              >
              <el-button
                type="primary"
                class="width120"
                @click="
                  () => {
                    this.dataForm = JSON.parse(
                      JSON.stringify(this.commandForm)
                    );
                    this.handleQuery();
                  }
                "
                >查询</el-button
              >
            </el-col>
          </el-row>
        </el-form>
      </div>
    </el-card>
    <el-card
      v-if="activeKey == '1'"
      class="textBox"
      style="min-width: 1200px; margin-bottom: -5px; margin-top: 15px"
    >
      <span class="numBox">
        <span>应付总额</span>
        <span class="symbol">￥</span>
        <span class="num">{{ info.fmtTotalAmount || 0.0 }}</span>
      </span>
      <span class="numBox">
        <span>已结算</span>
        <span class="symbol">￥</span>
        <span class="num">{{ info.fmtSuccessTotalAmount || 0.0 }}</span>
      </span>
      <span class="numBox">
        <span>未结算</span>
        <span class="symbol">￥</span>
        <span class="num">{{ info.fmtUnSuccessTotalAmount || 0.0 }}</span>
      </span>
    </el-card>
    <el-card style="margin-top: 20px; min-width: 1200px">
      <div class="switch">
        <el-switch v-model="isFixedTableH" inactive-text="固定表头">
        </el-switch>
        <el-button
          type="primary"
          v-if="isTep == 1 && activeKey == '1'"
          @click="handleBatClick"
          >批量处理</el-button
        >
        <div v-if="isTep == 2 && activeKey == '1'">
          <el-button @click="resetClick" class="width120">取消</el-button>
          <el-button type="primary" class="width120" @click="refundAll(1)"
            >批量结算</el-button
          >
        </div>
      </div>

      <el-table
        v-if="activeKey == '1'"
        :data="dataList"
        :height="fixedTableHeight"
        @selection-change="handleSelectionChange"
        ref="multipleTable"
      >
        <template slot="empty">
          <el-empty
            :image="require('@/assets/imgs/middleWork/k1.png')"
            :image-size="80"
            description="暂无相关数据"
          ></el-empty>
        </template>
        <el-table-column
          show-overflow-tooltip
          type="selection"
          :selectable="
            (row) =>
              (getUserInfo().userType == 'main_user' ||
                getUserInfo().userType == 'main_admin') &&
              row.status == 'created'
          "
          width="55"
          v-if="isPatch"
        ></el-table-column>
        <el-table-column width="30px" type=""></el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="payTime"
          align="center"
          label="创建时间"
          type=""
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.gmtCreated ? scope.row.gmtCreated : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="merchantOrderNo"
          align="center"
          label="商户订单号"
          type=""
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.merchantOrderNo ? scope.row.merchantOrderNo : "-" }}
            </div>
          </template>
        </el-table-column>
        <!-- <el-table-column
          show-overflow-tooltip
          prop="fmtOriginalAmount"
          sortable
          align="center"
          label="订单金额/元"
          type=""
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.fmtOrderAmount ? scope.row.fmtOrderAmount : "-" }}
            </div>
          </template>
        </el-table-column> -->
        <el-table-column
          show-overflow-tooltip
          prop="settleMemberName"
          align="center"
          label="收款方"
          type=""
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.children ? "多方" : scope.row.userName }}
            </div>
          </template>
        </el-table-column>
        <!-- <el-table-column width="30px"></el-table-column> -->
        <el-table-column
          show-overflow-tooltip
          prop="fmtSettleAmount"
          sortable
          align="center"
          label="应付金额/元"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.fmtAmount ? scope.row.fmtAmount : "0.00" }}
            </div>
          </template>
        </el-table-column>
        <!-- <el-table-column
          show-overflow-tooltip
          prop="amountType"
          align="center"
          label="分润类型"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.royaltyTypeName ? scope.row.royaltyTypeName : "-" }}
            </div>
          </template>
        </el-table-column> -->
        <el-table-column
          show-overflow-tooltip
          prop="settleFinish"
          align="center"
          label="结算状态"
        >
          <template slot-scope="scope">
            <div>
              <span
                :style="scope.row.status == 'succeeded' ? 'color: #F69C1F' : ''"
                >{{ scope.row.statusName ? scope.row.statusName : "-" }}</span
              >
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="address"
          align="center"
          label="结算方式"
        >
          <template slot-scope="scope">
            <div>
              {{ scope.row.royaltyWayName ? scope.row.royaltyWayName : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="act"
          align="center"
          label="操作"
        >
          <template slot-scope="scope">
            <div class="tab-commamd">
              <!-- <span>
                <el-button
                  v-if="scope.row.payformNo != null"
                  @click="goDetail(scope.row)"
                  type="text"
                  size="small"
                  >详情</el-button
                >
              </span> -->
              <span
                v-if="
                  (getUserInfo().userType == 'main_user' ||
                    getUserInfo().userType == 'main_admin') &&
                  scope.row.status == 'created'
                "
              >
                <el-button
                  @click="refundAll(0, scope.row.id)"
                  type="text"
                  size="small"
                  >结算</el-button
                >
              </span>
              <!-- <span
                v-if="
                  scope.row.settleFinish == 3 &&
                  scope.row.payformNo &&
                  scope.row.offlineSettle == 0
                "
              >
                <el-button
                  @click="handleClick1(scope.row)"
                  type="text"
                  size="small"
                  >标记结算</el-button
                >
              </span> -->
            </div>
          </template>
        </el-table-column>
      </el-table>
      <el-table
        v-if="activeKey == '2'"
        :data="dataList"
        :height="fixedTableHeight"
        @selection-change="handleSelectionChange"
        ref="multipleTable"
      >
        <template slot="empty">
          <el-empty
            :image="require('@/assets/imgs/middleWork/k1.png')"
            :image-size="80"
            description="暂无相关数据"
          ></el-empty>
        </template>
        <el-table-column
          show-overflow-tooltip
          type="selection"
          :selectable="
            (row) =>
              row.settleFinish == 0 &&
              row.payformNo &&
              row.settleMode == 'delay_settle'
          "
          width="55"
          v-if="isPatch"
        ></el-table-column>
        <el-table-column width="30px" type=""></el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="payTime"
          align="center"
          label="创建时间"
          type=""
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.gmtCreated ? scope.row.gmtCreated : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="merchantOrderNo"
          align="center"
          label="批次号"
          type=""
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.id ? scope.row.id : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="fmtOriginalAmount"
          sortable
          align="center"
          label="结算金额/元"
          type=""
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.fmtSettleAmount ? scope.row.fmtSettleAmount : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="settleMemberName"
          align="center"
          label="结算渠道"
          type=""
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{
                scope.row.settleChannelName ? scope.row.settleChannelName : "-"
              }}
            </div>
          </template>
        </el-table-column>
        <!-- <el-table-column width="30px"></el-table-column> -->
        <el-table-column
          show-overflow-tooltip
          prop="fmtSettleAmount"
          sortable
          align="center"
          label="结果"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.resultDes ? scope.row.resultDes : "-" }}
            </div>
          </template>
        </el-table-column>
        <!-- <el-table-column
          show-overflow-tooltip
          prop="amountType"
          align="center"
          label="分润类型"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.royaltyTypeName ? scope.row.royaltyTypeName : "-" }}
            </div>
          </template>
        </el-table-column> -->
        <el-table-column
          show-overflow-tooltip
          prop="settleFinish"
          align="center"
          label="批次状态"
        >
          <template slot-scope="scope">
            <div>
              <span
                :style="
                  scope.row.settleStatus == 'succeeded'
                    ? 'color: green'
                    : 'color: red'
                "
                >{{
                  scope.row.settleStatusName ? scope.row.settleStatusName : "-"
                }}</span
              >
            </div>
          </template>
        </el-table-column>

        <!-- <el-table-column
          show-overflow-tooltip
          prop="act"
          align="center"
          label="操作"
        >
          <template slot-scope="scope">
            <div class="tab-commamd">
              <span>
                <el-button
                  v-if="scope.row.payformNo != null"
                  @click="goDetail(scope.row)"
                  type="text"
                  size="small"
                  >详情</el-button
                >
              </span>
              <span
                v-if="
                  (getUserInfo().userType == 'main_user' ||
                    getUserInfo().userType == 'main_admin') &&
                  scope.row.status == 'created'
                "
              >
                <el-button
                  @click="refundAll(0, scope.row.id)"
                  type="text"
                  size="small"
                  >结算</el-button
                >
              </span>
              <span
                v-if="
                  scope.row.settleFinish == 3 &&
                  scope.row.payformNo &&
                  scope.row.offlineSettle == 0
                "
              >
                <el-button
                  @click="handleClick1(scope.row)"
                  type="text"
                  size="small"
                  >标记结算</el-button
                >
              </span>
            </div>
          </template>
        </el-table-column> -->
      </el-table>
    </el-card>
    <el-pagination
      layout="prev, pager, next, sizes, jumper"
      :page-sizes="[10, 20, 30, 40]"
      :page-size="pageSize"
      :current-page="pageNum"
      :total="total"
      @current-change="pageCurrentChangeHandle"
      @size-change="pageSizeChangeHandle"
    >
    </el-pagination>
    <!-- 详情抽屉 -->
    <detail-drawer
      :drawer.sync="drawer"
      :info="detailsInfo"
      :activeKey="activeKey"
    ></detail-drawer>

    <el-dialog
      class="customD"
      title=""
      :visible="settleDialog"
      :show-close="false"
      :close-on-click-modal="false"
      width="440px"
    >
      <div class="title">标记结算</div>
      <div class="explain">
        当分润失败后商户可以选择线下标记结算，表示已与其他分润方进行线下结算，订单状态为已结算，不能再次发起结算。
      </div>
      <div class="codeBox">
        <el-form
          :model="settleForm"
          ref="settleForm"
          label-width="0px"
          class="demo-ruleForm"
        >
          <el-form-item prop="settleFinish">
            <el-select
              v-model="settleForm.settleFinish"
              style="width: 100%"
              placeholder="请选择结算状态"
            >
              <el-option label="线下标记结算" :value="0"></el-option>
            </el-select>
          </el-form-item>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="settleDialog = false" style="width: 120px"
          >取消</el-button
        >
        <el-button type="primary" style="width: 120px" @click="handleSubmit"
          >确认</el-button
        >
      </div>
    </el-dialog>
  </div>
</template>

<script>
import mixin from "@/mixins/mixin";
import detailDrawer from "./detailDrawer.vue";
import { getUserInfo } from "@/utils/public";

// import elMerchantVue from "@/components/el-merchant.vue";
export default {
  mixins: [mixin],
  name: "caseAccountDetails",
  components: {
    detailDrawer,
    // elMerchantVue,
  },
  data() {
    return {
      settleDialog: false,
      settleForm: {
        settleFinish: 0,
      },
      isTep: 1, //表格按钮切换
      isPatch: false,
      drawer: false,
      detailsInfo: {},
      activeKey: "1",
      mixinViewModuleOptions: {
        getDataListURL: "/api/royalty/expendByPage",
        createdIsNeed: false,
      },
      restaurants: [],
      dataList: [],
      commandForm: {
        type: "",
        merchantIds: [],
        royaltyWay: "",
        settleChannel:"",
        // merchantId: [],
        date: [],
        status: "",
        settleStatus:""
      },
      multipleSelection: [],
      info: {},
    };
  },
  created() {
    this.dataForm = JSON.parse(JSON.stringify(this.commandForm));
    this.handleQuery();
  },
  watch: {
    "$store.state.testLine": {
      handler() {
        if (this.$route.name == this.$options.name) {
          this.handleQuery();
        }
      },
    },
    deep: true,
  },
  methods: {
    getUserInfo,
    tabClick() {
      console.log(this.activeKey);
      this.resetFields();
      if (this.activeKey == "2") {
        this.mixinViewModuleOptions.getDataListURL =
          "/api/royalty/settlementByPage";
      } else {
        this.mixinViewModuleOptions.getDataListURL =
          "/api/royalty/expendByPage";
      }
      this.dataForm = JSON.parse(JSON.stringify(this.commandForm));
      this.handleQuery();
    },
    resetClick() {
      this.isPatch = false;
      this.multipleSelection = [];
      this.$refs.multipleTable.clearSelection();
      this.isTep = 1;
    },
    handleBatClick() {
      this.isPatch = true;
      this.isTep = 2;
    },
    //重置操作
    resetFields() {
      this.resetForm("caseAccountDetailsForm");
      this.commandForm = {
        type: "",
        merchantIds: [],
        status: "",
        royaltyWay: "",
        settleChannel:"",
        // merchantId: [],
        date: [],
        settleStatus:""
      };
    },
    calc(oriList) {
      console.log(oriList);
      let newlist = oriList.map((item) => {
        if (item.children.length == 1) {
          return {
            ...item,
            settleMemberName: item.children[0].settleMemberName,
            fmtSettleAmount: item.children[0].fmtSettleAmount,
            fmtFeeAmount: item.children[0].fmtFeeAmount,
            children: null,
          };
        } else {
          return item;
        }
      });
      //console.log(newlist);
      return newlist;
    },
    setId(val) {
      console.log(val);
      this.commandForm.merchantIds = [val];
      // this.restaurants = [];
      // let obj = this.restaurants.find((item) => item.memberName == val);
      // this.dataForm.memberIds = [obj.id];
      // console.log(this.dataForm.memberIds);
    },
    setId1() {
      if (this.restaurants.length != 0) {
        this.restaurants = [];
      }
    },
    remoteMethod(query) {
      if (query !== "") {
        this.getMerchantList(query);
      } else {
        this.merchantList = [];
      }
    },
    getMerchantList(val) {
      //console.log(val);
      this.$http
        .get("/api/royalty/getMemberUserByAppIdAndMerchanrId?userName=" + val)
        .then((res) => {
          if (res.code === "0000") {
            //console.log(res.data);
            this.restaurants = res.data;
          }
        });
    },
    goDetail(row) {
      this.$http
        .get(`/api/settle/payout/getSettleDetailById?id=${row.id}`)
        .then((res) => {
          if (res.code === "0000") {
            console.log(res.data);
            this.detailsInfo = res.data;
            this.drawer = true;
          }
        });
      // this.$router.push({ path: "/caseAccount/detail", query: { id: row.id } });
    },
    handleClick(row) {
      // let that = this;
      // that
      //   .$confirm(
      //     "确认结算后，分账金额会结算至对应收款方，是否确认结算?",
      //     "提示",
      //     {
      //       confirmButtonText: "确定",
      //       customClass: "confirm",
      //       cancelButtonText: "取消",
      //       showClose: false,
      //       closeOnClickModal: false,
      //       closeOnPressEscape: false,
      //       type: "warning",
      //       center: true,
      //     }
      //   )
      //   .then(() => {
      //     this.$http
      //       .post("/api/settle/delayConfirm", { orderId: row.id })
      //       .then((res) => {
      //         if (res.code === "0000") {
      //           if (res.sub_code == "SYS.SUCCESS") {
      //             this.$message.success("结算成功！");
      //           } else if (res.sub_code == "SYS.PROCESSING") {
      //             this.$message.warning("结算已提交！");
      //           } else {
      //             this.$message.error(`${res.msg}`);
      //           }
      //         }
      //         this.handleQuery();
      //       });
      //   });
    },
    handleClick1(row) {
      this.curRow = row;
      this.settleDialog = true;
      // let that = this;
      // that
      //   .$confirm(
      //     "当分账失败后商户选择标记，表示已与各分账接收方进行线下结算。该笔订单则不再发起分账，分账金额立即解冻进入分账发起方账户中。",
      //     "标记结算",
      //     {
      //       confirmButtonText: "确定",
      //       customClass: "confirm",
      //       cancelButtonText: "取消",
      //       showClose: false,
      //       closeOnClickModal: false,
      //       closeOnPressEscape: false,
      //       // type: "warning",
      //       center: true,
      //     }
      //   )
      //   .then(() => {
      //     this.$http
      //       .post("/api/settle/updateOfflineSettle", { id: row.id })
      //       .then((res) => {
      //         if (res.code === "0000") {
      //           this.$message.success("标记成功！");
      //         } else {
      //           this.$message.error(`${res.msg}`);
      //         }
      //         this.handleQuery();
      //       });
      //   });
    },
    handleSubmit() {
      this.$http
        .post("/api/settle/updateOfflineSettle", { id: this.curRow.id })
        .then((res) => {
          if (res.code === "0000") {
            this.$message.success("标记成功！");
            this.handleQuery();
          } else {
            console.log(111);
            this.$message.error(`${res.msg}`);
          }
        });
    },
    handleQuery() {
      if (this.dataForm.date && this.dataForm.date.length) {
        this.dataForm.createStartTime = this.dataForm.date[0];
        this.dataForm.createEndTime = this.dataForm.date[1];
      } else {
        this.dataForm.createStartTime = "";
        this.dataForm.createEndTime = "";
      }
      if (this.dataForm.merchantIds.length) {
        this.dataForm.settleMemberIds = this.dataForm.merchantIds;
      } else {
        this.dataForm.settleMemberIds = [];
      }
      // this.dataForm.settleFinish = this.commandForm.settleFinish;
      this.$http
        .post("/api/royalty/expend/statistics", { ...this.dataForm })
        .then((res) => {
          if (res.code === "0000") {
            this.info = res.data;
          }
        });
      this.getDataList();
    },
    handleSelectionChange(val) {
      console.log(val);
      // this.multipleSelection = val.map(item => item.id);
      this.multipleSelection = val;
    },
    refundAll(idx, id) {
      // this.isPatch = true;
      // console.log(this.multipleSelection);
      //批量结算
      if (idx == 1) {
        if (this.multipleSelection.length == 0) {
          return this.$message.warning("请先选择结算订单");
        }
        this.refundIds = this.multipleSelection.map((item) => item.id);
      } else {
        //单笔结算
        this.refundIds = [id];
      }
      console.log(this.refundIds);
      this.$router.push({
        path: "/caseAccount/caseAccountSettles",
        query: { ids: JSON.stringify(this.refundIds) },
      });
      // this.refundDialog = true;
      // this.isRefundAll = true;
    },
    rowClassNameFn({ row }) {
      if (!row.children) {
        return "showSelect";
      }
    },
  },
};
</script>

<style scoped lang="scss">
.customD {
  .title {
    width: 160px;
    height: 24px;
    font-size: 20px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: rgba(0, 0, 0, 0.85);
    line-height: 24px;
  }
  .explain {
    margin-top: 13px;
    font-size: 14px;
    color: rgba(0, 0, 0, 0.65);
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
  }
  .codeBox {
    margin-top: 28px;
  }
  .codeBtn {
    width: 133px;
    height: 32px;
    background: #25b5d9;
    color: #fff;
    margin-left: 10px;
    border-radius: 2px;
    text-align: center;
    border: none;
  }
  :deep(.el-dialog) {
    background: transparent;
    box-shadow: none;
  }
  :deep(.el-dialog__body) {
    height: 336px;
    padding: 41px 40px;
    padding-bottom: 48px;
    background: #fff;
    border-radius: 16px;
    margin-bottom: -82px;
  }
  :deep(.dialog-footer) {
    margin-right: 22px;
  }
}

.tab-commamd {
  width: 100%;
  display: flex;
  justify-content: space-around;
}
.width120 {
  width: 120px;
}

.switch {
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
:deep(.showSelect) {
  td:nth-child(1) {
    .cell {
      visibility: hidden;
    }
  }
}
:deep(.el-table__expand-icon) {
  // position: absolute;
  // left:140px;
  float: left;
}
</style>
